//package com.shop.loan.handler;
//
//
//import com.shop.loan.model.vo.GeoPoint;
//import com.shop.loan.util.GeoPointConverter;
//import org.apache.ibatis.type.BaseTypeHandler;
//import org.apache.ibatis.type.JdbcType;
//import org.apache.ibatis.type.MappedJdbcTypes;
//import org.apache.ibatis.type.MappedTypes;
//import org.springframework.stereotype.Component;
//
//import java.sql.CallableStatement;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//
//@Component //注入Bean,全局配置使其自动转换，不需要在sql层手动指定
//@MappedJdbcTypes(JdbcType.OTHER) // JdbcType只能用OTHER类型，没有point类型
//@MappedTypes(GeoPoint.class)
//public class GeoPointTypeHandler extends BaseTypeHandler<GeoPoint> {
//    GeoPointConverter converter = new GeoPointConverter();
//    @Override
//    public void setNonNullParameter(PreparedStatement ps, int i, GeoPoint parameter, JdbcType jdbcType) throws SQLException {
//        ps.setBytes(i, converter.to(parameter));
//    }
//    @Override
//    public GeoPoint getNullableResult(ResultSet rs, String columnName) throws SQLException {
//        return converter.from(rs.getBytes(columnName));
//    }
//    @Override
//    public GeoPoint getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
//        return converter.from(rs.getBytes(columnIndex));
//    }
//    @Override
//    public GeoPoint getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
//        return converter.from(cs.getBytes(columnIndex));
//    }
//}
